<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>文章列表</title>
    <style>
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
        }
        th {
            background-color: #f2f2f2;
            text-align: left;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        tr:hover {
            background-color: #ddd;
        }
    </style>
</head>
<body>
    <h1>文章列表</h1>
    <table>
        <thead>
            <tr>
                <th>编号</th>
                <th>标题</th>
                <th>栏目</th>
                <th>日期</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for article in articles %}
                <tr>
                    <td>{{ article.id}}</td>
                    <td>{{ article.title}}</td>
                    <td>{{ article.column}}</td>
                    <td>{{ article.date }}</td>
                    <td>
                        <a href="{% url 'article_edit' article.pk %}">编辑</a>|
                        <form action="{% url 'article_delete' article.pk %}" method="post" style="display:inline;">
                            {% csrf_token %}
                            <button type="submit" onclick="return confirm('确定要删除此文章吗？');" style="background:none;border:none;color:red;cursor:pointer;">删除</button>
                        </form>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="5">暂未添加文章</td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
    <br>
    <a href="{% url 'article_create' %}">创建新文章</a>

</body>
</html>